var z = new zjm();
window.onload = function () {
    info();
};
function info() {
    z.ax(
        "get",
        "/novel/novel",
        null,
        (res) => {
            console.log(res);
            for (var i = 0; i < Math.ceil(res.length / 2); i++) {
                $(".novelInfo").append(
                    `<div class="novelInfoRow"></div>`
                );
                for (var j = 0; j < 2; j++) {
                    $(".novelInfoRow").eq(i).append(
                        `<a href="javascript:void(0);" onclick="isLogin(${res[i * 2 + j].id})" class="novelInfoRowBox">
                                <div class="novelInfoRowBoxImg">
                                    <img src="${res[i * 2 + j].cover}" alt="">
                                </div>
                                <div class="novelInfoRowBoxText">
                                    <div class="novelInfoRowBoxTextFlex">
                                        <div class="novelInfoRowBoxTextTitle">
                                            ${res[i * 2 + j].title}
                                        </div>
                                        <div class="novelInfoRowBoxTextAuthor">
                                            ${res[i * 2 + j].author + " | " + res[i * 2 + j].categoryName + " | 连载中"}
                                        </div>
                                        <div class="novelInfoRowBoxTextIntroduce">
                                            ${res[i * 2 + j].intro}
                                        </div>
                                        <div class="novelInfoRowBoxTextOther">
                                            999万字 | 第9999章
                                        </div>
                                    </div>
                                </div>
                            </a>
                        `)
                }
            }
            for (var i = 0; i < 6; i++) {
                $(".centerRightBoxInfo").append(
                    `<div class="centerRightBoxInfoRow">
                            <div>
                                ${res[i].title}
                            </div>
                            <div style="display: flex;">
                                <span class="glyphicon glyphicon-fire" style="color: red;" aria-hidden="true"></span>
                                <div style="color: red;">${123 - i * 2}万</div>
                            </div>
                        </div>
                    `
                );
            }
        }
    );
    z.ax(
        "get",
        "/novel/category",
        null,
        (res) => {
            for (var i = 0; i < 6; i++) {
                $(".centerLeftBoxCtegoryRowInfo").append(
                    `<a href="#">${res[i].categoryName}</a>`
                )
            }
        }
    )
}
function isLogin(id) {
    var isLogin = true;
    if (isLogin) {
        window.location.href = "./BookDetail.html?id=" + id;
    }
}